﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace Proggy.Data.Entities
{
    /// <summary>
    /// Base node class
    /// </summary>
    public abstract class NodeBase
    {
        /// <summary>
        /// Optional - a unique alias for this node
        /// </summary>
        [MaxLength(64, ErrorMessage="Unique alias cannot be longer than 64 characters in length")]
        [MinLength(6, ErrorMessage="Unique alias is optional, however if it entered, it must be at least 6 characters long")]
        [RegularExpression("^[a-zA-Z0-9_]*$", ErrorMessage = "Unique alias can only contain uppercase letters, numbers and underscores (_)")]
        [Display(Name = "Unique alias")]        
        public string UniqueAlias { get; set; }

        /// <summary>
        /// The name of this node
        /// </summary>
        [MaxLength(100)]
        [Display(Name = "Content name")]
        [Required(AllowEmptyStrings = false)]
        [MinLength(1)]
        public string Name { get; set; }

        /// <summary>
        /// The url portion for this node
        /// </summary>
        [MaxLength(50)]
        [RegularExpression("^[a-z0-9-]*$", ErrorMessage = "Url can only contain lowercase letters, numbers and dashes (-)")]
        [Display(Name = "Url slug")]
        [Required(AllowEmptyStrings = true)]
        public string UrlPortion { get; set; }

        /// <summary>
        /// The name of the template (eg "Home" would become "~/Views/Templates/Home.cshtml")
        /// </summary>
        [Display(Name = "Template name")]
        [MaxLength(255)]
        public string Template { get; set; }

        /// <summary>
        /// The alias used for matching controller / content model (ie "News" would be "NewsController" and "NewsContentModel")
        /// </summary>
        [Required]
        [Display(Name = "Content type")]
        [MaxLength(255)]
        public string TypeAlias { get; set; }

        /// <summary>
        /// The assembly in which the view model and controller reside
        /// </summary>
        //[Required]
        public string TypeAssemblyName { get; set; }

        /// <summary>
        /// The namespace in which the controller resides
        /// </summary>
        //[Required]
        public string ControllerNameSpace { get; set; }

        /// <summary>
        /// The namespace in which the view model resides
        /// </summary>
        //[Required]
        public string ContentModelNameSpace { get; set; }

        /// <summary>
        /// The saved data against this node
        /// </summary>
        public string SavedContentModelData { get; set; }

        /// <summary>
        /// Last updated
        /// </summary>
        public DateTime LastUpdated { get; set; }

        /// <summary>
        /// First created
        /// </summary>
        public DateTime FirstCreated { get; set; }

        /// <summary>
        /// Last updated
        /// </summary>
        //[Required]
        public string LastUpdatedUsername { get; set; }

        /// <summary>
        /// First created
        /// </summary>
        //[Required]
        public string FirstCreatedUsername { get; set; }
    }
}
